package logic

import (
	"context"
	"gorm.io/gorm"
	"renting-demo/model/mysql"

	"renting-demo/goods_srv/goods"
	"renting-demo/goods_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelProductLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelProductLogic {
	return &DelProductLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品下架
func (l *DelProductLogic) DelProduct(in *goods.DelProductReq) (*goods.DelProductResponse, error) {
	// todo: add your logic here and delete this line
	res := mysql.RemovedGoods(mysql.Product{
		Model: gorm.Model{ID: uint(in.GoodsID)},
	})
	return &goods.DelProductResponse{
		Status: res.Status,
	}, nil
}
